package com.azdebugit.collection.utils.test;

import org.apache.commons.collections4.map.LRUMap;

public class LRUMapApp {

    public static void main(String[] args) {
        LRUMap<String, String> lruMap = new LRUMap<>(3);

        System.out.println("size=" + lruMap.size());
        System.out.println("maxSize=" + lruMap.maxSize());
        System.out.println("isFull=" + lruMap.isFull());

        System.out.println();
        lruMap.put("id", "1");
        lruMap.put("code", "A0001");
        lruMap.put("name", "第一个");

        System.out.println(lruMap);
        System.out.println("size=" + lruMap.size());
        System.out.println("maxSize=" + lruMap.maxSize());
        System.out.println("isFull=" + lruMap.isFull());

        System.out.println();
        // 使用了id, 所以key为id不会被挤出去, code被挤出去
        lruMap.get("id");

        lruMap.put("email", "XXX");
        System.out.println(lruMap);
        System.out.println("size=" + lruMap.size());
        System.out.println("maxSize=" + lruMap.maxSize());
        System.out.println("isFull=" + lruMap.isFull());
    }

}
